package com.cxf.windex.rest.admin;

import com.cxf.windex.base.msg.TableResultResponse;
import com.cxf.windex.base.rest.BaseRestController;
import com.cxf.windex.biz.VoiceTemplatesBiz;
import com.cxf.windex.entity.JsType;
import com.cxf.windex.entity.VoiceTemplates;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 语音模板控制类
 *
 * @author chenxf
 * @version 1.0
 * @date 2018-12-03 10:34
 **/
@Api(tags = {"村广通[后台] - 语音模板接口"})
@Controller
@RequestMapping("admin/voiceTemplates")
public class VoiceTemplatesController extends BaseRestController<VoiceTemplatesBiz, VoiceTemplates> {
    @ApiOperation(value = "查询语音模板列表", notes = "查询语音模板列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "limit", value = "记录数 默认10",   paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "offset", value = "页码 默认 1",   paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "orderStr", value = "排序 默认desc",  paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "tags", value = "标签",  paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "name", value = "模板名称",   paramType = "query", dataType = "String")
    })
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    public TableResultResponse<VoiceTemplates> list(
            @RequestParam(defaultValue = "10") int limit, @RequestParam(defaultValue = "1") int offset,
            @RequestParam(defaultValue = "desc") String orderStr, String tags, String name) {
        List<VoiceTemplates> items = baseBiz.list(limit, offset, orderStr, name, tags);
        PageInfo<VoiceTemplates> pageInfo = new PageInfo<>(items);
        return new TableResultResponse<>(Integer.parseInt(String.valueOf(pageInfo.getTotal())),
                offset, limit,
                items);
    }
}
